import { useDictStore } from '@/store/modules/dict';
import { renderOptionTag } from '@/utils';
import { NTag } from 'naive-ui';
import { h } from 'vue';
const dict = useDictStore();
const msgWxMap = {
  1: '审核中',
  2: '审核通过',
  3: '提现异常',
  4: '提现成功',
};

const msgMap = {
  1: '处理中',
  2: '打款中',
  3: '提现异常',
  4: '提现成功',
};

export const statusOptions = [
  {
    value: 1,
    label: '处理中',
  },
  {
    value: 2,
    label: '打款中',
  },
  {
    value: 3,
    label: '提现异常',
  },
  {
    value: 4,
    label: '提现成功',
  },
];

export const columns = [
  {
    title: '提现ID',
    key: 'id',
    width: 80,
  },
  {
    title: '用户ID',
    key: 'memberId',
    width: 80,
  },
  {
    title: '用户名称',
    key: 'memberId',
    width: -1,
    render(row) {
      if (row.adminMemberRoleId === 210) {
        return row.adminMemberNickname;
      } else {
        return row.adminMemberRealName ? row.adminMemberRealName : row.adminMemberNickname;
      }
    },
  },
  {
    title: '门店名称',
    key: 'storeName',
    width: -1,
  },
  {
    title: '角色',
    key: 'adminMemberRoleId',
    align: 'center',
    width: 100,
    render(row) {
      if (row.adminMemberRoleId === 210) {
        return h(NTag, { type: 'success', bordered : false }, { default: () => '用户' });
      } else if (row.adminMemberRoleId === 211) {
        return h(NTag, { type: 'info', bordered : false }, { default: () => '销氪' });
      } else if (row.adminMemberRoleId === 100 || row.storeId !== 0) {
        return h(NTag, { type: 'warning', bordered : false }, { default: () => '门店' });
      } else if (row.adminMemberRoleId === 212) {
        return h(NTag, { type: 'error', bordered : false }, { default: () => '服务商' });
      }
    },
  },
  {
    title: '提现方式',
    key: 'withdrawType',
    width: 100,
    render(row) {
      return renderOptionTag('xxb_zj_txfs', row.withdrawType);
    },
  },
  {
    title: '提现金额',
    key: 'money',
    render(row) {
      return row.money.toFixed(2);
    },
    width: 100,
  },
  {
    title: '手续费',
    key: 'fee',
    render(row) {
      return row.fee.toFixed(2);
    },
    width: 100,
  },
  {
    title: '最终到账',
    key: 'lastMoney',
    render(row) {
      return row.lastMoney.toFixed(2);
    },
    width: 100,
  },
  // 状态
  // {
  //   title: '状态',
  //   key: 'status',
  //   width: 100,
  //   render(row) {
  //     return renderOptionTag('xxb_zj_txgl', row.status);
  //   },
  // },
  {
    title: '处理结果',
    key: 'msg',
    render(row) {
      return h(
        NTag,
        {
          style: {
            marginRight: '6px',
          },
          type: row.status == 1 ? 'info' : row.status == 2 ? 'info' : row.status == 3 ? 'warning' : 'success',
          bordered: false,
        },
        {
          default: () => {
            if (row.withdrawType == 1) {
              return row.msg == '' ? msgMap[row.status] : row.msg;
            } else if (row.withdrawType == 2) {
              return row.msg == '' ? msgWxMap[row.status] : row.msg;
            }
          },
        }
      );
    },
    width: -1,
  },
  // {
  //   title: '申请IP',
  //   key: 'ip',
  //   width: 180,
  // },
  {
    title: '处理时间',
    key: 'handleAt',
    width: 180,
  },
  {
    title: '申请时间',
    key: 'createdAt',
    width: 180,
  },
];

// 加载字典数据选项
export function loadOptions() {
  dict.loadOptions(['xxb_zj_txgl', 'xxb_zj_txfs']);
}